package com.osgix.authorize.entity;

// Generated 2010-6-27 20:39:35 by Hibernate Tools 3.3.0.GA

import static javax.persistence.GenerationType.IDENTITY;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;

/**
 * Authority generated by hbm2java
 */
@Entity
@Table(name = "authority", catalog = "base", uniqueConstraints = @UniqueConstraint(columnNames = "name"))
public class Authority implements java.io.Serializable {

	private Long authorityId;
	private String name;
	private Set<RoleAuthority> roleAuthorities = new HashSet<RoleAuthority>(0);

	public Authority() {
	}

	public Authority(String name) {
		this.name = name;
	}

	public Authority(String name, Set<RoleAuthority> roleAuthorities) {
		this.name = name;
		this.roleAuthorities = roleAuthorities;
	}

	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "authority_id", unique = true, nullable = false)
	public Long getAuthorityId() {
		return this.authorityId;
	}

	public void setAuthorityId(Long authorityId) {
		this.authorityId = authorityId;
	}

	@Column(name = "name", unique = true, nullable = false)
	public String getName() {
		return this.name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@OneToMany(fetch = FetchType.LAZY, mappedBy = "authority")
	public Set<RoleAuthority> getRoleAuthorities() {
		return this.roleAuthorities;
	}

	public void setRoleAuthorities(Set<RoleAuthority> roleAuthorities) {
		this.roleAuthorities = roleAuthorities;
	}

}
